import React, { useRef, useState, useEffect } from 'react';
import { Radio, Row, Col, Card, Space, } from 'antd';
import { connect, history } from 'umi';
import { qaType_status } from '@/common/contact'
import TableDataBlock from '@/components/TableDataBlock';
import Indentation from '@/components/Indentation';
const OfflineQAList = (props) => {
    const { list = {}, dispatch, loading } = props
    const { location = {} } = history
    const { query = {} } = location
    const { accessId } = query
    const childRef = useRef();
    // table 表头
    const btnExtra = [
        {
            text: '新增',
            onClick: () => {
                history.push({
                    pathname: '/answeringModule/OfflineDetail',
                    query: {
                        ...query
                    }
                })
            }
        }
    ]
    const searchItems = [
        // {
        //     label: '答疑类型',
        //     name: 'qaTypes',
        //     type: 'select',
        //     select: qaType_status,
        // },
    ];
    const getColumns = [

        {
            title: '标题',
            dataIndex: 'title',

        },
        {
            title: '老师名称',
            dataIndex: 'teacherNames',
        },
        {
            title: '开始时间',
            dataIndex: 'startDate',
        },
        {
            title: '结束时间',
            dataIndex: 'endDate',
        },

        {
            title: '学科名称',
            dataIndex: 'subjectNames',
        },
        {
            title: '价格类型',
            dataIndex: 'priceType',
            render: (e) => {
                return {
                    free: "免费",
                    price: '付费'
                }[e]
            }
        },
        {
            title: '价格',
            dataIndex: 'price',
        },
        {
            title: '价格积分',
            dataIndex: 'integralPrice',
        },
        {
            title: '消耗答疑次数',
            dataIndex: 'priceQaAmount',
        },
        {
            title: '校区名称',
            dataIndex: 'campusName',
        },
        {
            title: '班级名称',
            dataIndex: 'classroomName',
        },
        {
            title: '地址',
            dataIndex: 'fullAddress',
            render: (e) => {
                return <Indentation str={e}></Indentation>
            }
        },
        {
            title: '备注',
            dataIndex: 'remark',
            render: (e) => {
                return <Indentation str={e}></Indentation>
            }
        },

        {
            type: 'handle',
            width: 200,
            dataIndex: 'id',
            render: (val, record) => [
                {
                    auth: true,
                    title: '编辑',
                    type: 'edit',
                    click: () => {
                        history.push({
                            pathname: '/answeringModule/OfflineDetail',
                            query: {
                                ...query,
                                id: record.id
                            }
                        })
                    },
                },
            ],
        },
    ];
    return <Card title='线下答疑'>
        <Col span={24}>
            <TableDataBlock
                btnExtra={btnExtra}
                params={{ teachingModes: 'offline' }}
                cRef={childRef}
                loading={loading}
                // searchItems={searchItems}
                columns={getColumns}
                rowKey={(record) => `${record.id}`}
                dispatchType="answering/fetchListOfflineQASchedule"
                {...list}
            ></TableDataBlock>
        </Col>
    </Card>

}
export default connect(({ answering, loading }) => ({
    list: answering.teacherScheduleList,
    loading: loading.effects['answering/fetchListOfflineQASchedule'],
}))(OfflineQAList);
